import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

// 路由重复问题
const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(err => err)
}

const routes = [{
        path: '/home',
        redirect: '/'
    },
    {
        path: '/',
        name: 'home',
        component: () =>
            import ('../pages/home'),
        meta: {
            title: '首页'
        }
    },
]


const router = new VueRouter({
    routes
})
// router.beforeEach((to, from, next) => {
//     /* 路由发生变化修改页面title */
//     if (to.meta.title) {
//       document.title = to.meta.title
//     }
//     next()
//   })
export default router